<template>
  <div ref="mainCon" class="container">
    <!-- 企业详情 -->
    <el-row v-if="!hiddleToolBar" class="titleBox clearfix">
      <div class="fl" style="width: 100%">
        <span class="blockTitle">
          <i class="icon iconfont iconfanhui1" @click="goBack"></i>
          {{ querys.companyName || '--' }}
        </span>
        <p>
          <span class="code"
            >统一社会信用代码：<span>{{ querys.uscc || '--' }}</span></span
          >
          <span v-if="isReg">
            <span class="code"
              >企业联系人：<span>{{ qyDetail.transactor || '--' }}</span></span
            >
            <span class="code"
              >联系方式：<span>{{ qyDetail.transactorTel || '--' }}</span></span
            >
            <span class="code"
              >座机号码：<span>{{ qyDetail.landlineTel || '--' }}</span></span
            >
            <el-link
              type="primary"
              class="goSeeDetail"
              @click="goSeeDetail"
              v-hasBtn="'employerInfoList:detail'"
              >查看基本信息>></el-link
            >
          </span>
          <span v-else class="code">该企业尚未入驻平台</span>
        </p>
      </div>
    </el-row>
    <div class="mainCon">
      <el-row class="toolbar searchInputWidth" style="padding-bottom: 0">
        <el-form :inline="true" :model="filterField" ref="searchConditions">
          <el-col :lg="8" :xl="6">
            <el-form-item label="项目名称" class="row-padding-bottom">
              <el-input
                v-model="filterField.projectName"
                placeholder="输入项目名称"
                clearable
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :lg="8" :xl="6">
            <el-form-item label="项目状态" class="row-padding-bottom">
              <el-select
                v-model="filterField.status"
                filterable
                placeholder="请选择"
                clearable
              >
                <el-option
                  v-for="item in statusOptions"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-form-item>
            <el-button
              type="primary"
              icon="icon iconfont iconchazhao1"
              @click="searchList"
              class="searchBtn"
            >
              <span>搜索</span>
            </el-button>
          </el-form-item>
        </el-form>
      </el-row>
      <div class="spacing"></div>
      <div
        ref="tableBox"
        :class="hiddleToolBar ? 'tableBoxCur tableBox' : 'tableBoxCur'"
      >
        <el-table
          ref="tableBox1"
          :max-height="tableHeight"
          :data="tableList"
          v-loading="loading"
          :header-cell-style="{ background: '#eef1f6', color: '#606266' }"
          highlight-current-row
          stripe
          style="border: 1px solid #dfe6ec"
          @sort-change="sortChange"
        >
          <el-table-column prop="projectName" label="项目名称" width="230">
            <template slot-scope="scope">
              <copyText
                :tableIndex="scope.$index"
                :copyTextName="scope.row.projectName"
                :columnName="'projectName'"
              ></copyText>
            </template>
          </el-table-column>
          <el-table-column
            prop="statusDesc"
            label="项目状态"
            align="center"
            :formatter="formatTd"
            min-width="120"
          ></el-table-column>
          <el-table-column
            prop="constructionTypetDesc"
            label="参建类型"
            align="center"
            :formatter="formatTd"
            min-width="120"
          ></el-table-column>
          <el-table-column
            prop="peopleTotal"
            label="总人数"
            min-width="120"
            align="center"
            sortable="custom"
            :formatter="formatTd"
          ></el-table-column>
          <el-table-column
            prop="balance"
            label="工资专户余额"
            min-width="180"
            align="center"
            sortable="custom"
            :formatter="formatTd"
          ></el-table-column>
          <el-table-column
            prop="saTotal"
            label="代发总金额"
            min-width="180"
            align="center"
            sortable="custom"
            :formatter="formatTd"
          ></el-table-column>
          <el-table-column
            prop="archiveDate"
            label="建档日期"
            min-width="160"
            align="center"
            sortable="custom"
            :formatter="formatTd"
          ></el-table-column>
          <el-table-column
            label="操作"
            align="left"
            fixed="right"
            :formatter="formatTd"
            width="110"
          >
            <template slot-scope="scope">
              <el-link type="primary" @click="toDetail(scope.$index, scope.row)"
                >项目详情</el-link
              >
            </template>
          </el-table-column>
          <!-- 表格数据为空时，页面显示 -->
          <div slot="empty" v-show="isShow">
            <emptyTable emptyText="暂无相关信息"></emptyTable>
          </div>
        </el-table>
        <!-- filterField为搜索条件 -->
        <!-- getTableList为获取子组件的数据 -->
        <Pagination
          ref="pagination"
          @getList="getTableList"
          :filterField="filterField"
          :requestUrl="requestUrl"
        ></Pagination>
      </div>
    </div>
  </div>
</template>

<script>
import scrollTable from '@/mixin/scrollTable.js'

import { mapState, mapActions } from 'vuex'
export default {
  name: 'constructEmployingUnitDetail',
  mixins: [scrollTable],
  data() {
    return {
      //表格数据
      tableList: [],
      requestUrl: 'api-p/projectstats/expand/construction/projects',
      date: [],
      //搜索条件
      filterField: {
        pbUscc: '', //uscc
        projectName: '', //项目名称
        status: '', //项目状态
      },
      isShow: false, //列表加载
      loading: true,
      qyDetail: {
        name: '',
        uscc: '',
        transactor: '',
        transactorTel: '',
        landlineTel: '',
        id: '',
      },
      querys: {
        uscc: '',
        companyName: '',
      },
      isReg: true, //企业是否注册
    }
  },
  created() {
    const { uscc, companyName } = this.$route.query
    this.filterField.pbUscc = uscc
    this.querys = { uscc, companyName }
    this.$nextTick(function () {
      this.$refs.pagination.getTableListData()
    })
    this.getStatus({})
    this.getQyDetail()
  },
  computed: {
    ...mapState(['statusOptions']),
  },
  methods: {
    ...mapActions(['getStatus']),
    getTableList(data) {
      this.tableList = data
      this.loading = false
      if (this.tableList.length < 1) {
        this.isShow = true
      }
    },
    // 搜索
    searchList() {
      this.$refs.pagination.getTableListData()
    },
    //项目详情
    toDetail(index, row) {
      this.$router.push({
        path: '/home/monitorProjectManagement/projectDetail',
        name: 'projectDetail',
        query: {
          projectId: row.projectId,
          type: 'projectDetail',
        },
      })
      this.$store.commit('CHANGE_SLIDER_NAME', {
        oldUrl: '/home/project/projectList',
        newUrl: this.$router.currentRoute.fullPath,
      })
    },
    getQyDetail() {
      this.axios({
        method: 'post',
        url: 'api-c/company/base/getbyuscc',
        data: {
          uscc: this.filterField.pbUscc,
        },
      })
        .then(
          (response) => {
            if (!response.data.hasError) {
              //企业是否注册
              this.isReg = response.data.result.isReg
              this.qyDetail = response.data.result
            } else {
              this.$message({
                message: response.data.errorMsg,
                type: 'error',
              })
            }
          },
          (response) => {}
        )
        .catch((error) => {})
    },
    goSeeDetail() {
      this.$router.push({
        name: 'employerRecordDetail',
        path: 'home/enterpriseSet/employerRecordDetail',
        query: {
          companyId: this.qyDetail.id,
          routeName: 'constructEmployingUnitDetail',
        },
      })
      this.$store.commit('CHANGE_SLIDER_NAME', {
        oldUrl: '/home/enterpriseSet/employerInfoList',
        newUrl: this.$router.currentRoute.fullPath,
      })
    },
    goBack() {
      this.$router.push({
        name: 'constructEmployingUnitList',
        path: '/home/constructEmployingUnit/constructEmployingUnitList',
      })
      this.$store.commit('GOBACK_NAME', {
        oldUrl: '/home/constructEmployingUnit/constructEmployingUnitListn',
        newUrl: this.$router.currentRoute.fullPath,
      })
    },
  },
}
</script>

<style lang="less" scoped>
.mainCon {
  @media only screen and (max-width: 1366px) {
    /deep/.searchInputWidth .el-form--inline .el-form-item__label {
      width: 80px;
    }
  }
}

.titleBox {
  // background: #e4ebf1;
  padding: 16px 24px;
  border-bottom: 0;
  margin-bottom: 0;
  .blockTitle {
    font-weight: bold;
    font-size: 18px;
    color: #333;
    // line-height: 40px;
    .iconfanhui1 {
      font-size: 20px;
      margin-right: 6px;
      cursor: pointer;
    }
  }
  p {
    margin-top: 10px;
    position: relative;
    &:after {
      position: absolute;
      right: -24px;
      top: 35px;
      left: -24px;
      height: 1px;
      content: '';
      -webkit-transform: scaleY(0.5);
      transform: scaleY(0.5);
      background-color: #e3e7e9;
      z-index: 10;
    }
  }
  // .qyInfo {
  //     width:66px;
  //     height:66px;
  //     margin-right:12px;
  //     img {
  //         width:100%;
  //         height:100%;
  //     }
  // }
  .code {
    font-size: 14px;
    color: #666;
    margin-left: 30px;
  }
  .goSeeDetail {
    font-size: 14px;
    margin-left: 30px;
  }
}
@import '../../../static/css/filterArea.less';
</style>
